"""
URL configuration for 大疆 project.

The urlpatterns list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import path
from django.shortcuts import redirect
from Login import views as login_views
from Home import views as home_views
from Home import auth_views
# 迭代器功能已移动到 Home.views 中
from utils.gitee_oauth import GiteeOAuth
from utils.feishu_oauth import FeishuOAuth
from Iterator import views as iterator_views
from recognition import urls as recognition_urls

urlpatterns = [
    path('admin/', admin.site.urls),
    path('user/login', login_views.login),
    path('user/login/', login_views.login),
    path('user/info', login_views.get_user_info),
    path('user/info/', login_views.get_user_info),
    path('user/register', login_views.register),
    path('user/register/', login_views.register),
    path('sms/send', login_views.send_sms_code),
    path('sms/send/', login_views.send_sms_code),
    path('sms/login', login_views.sms_login),
    path('sms/login/', login_views.sms_login),
    path('sms/status', login_views.check_sms_status),
    path('sms/status/', login_views.check_sms_status),
    path('Login/ding', login_views.dingtalk_login),
    path('Login/ding/callback', login_views.dingtalk_callback),
    
    # Gitee OAuth路由
    path('oauth/gitee/login', lambda request: redirect(GiteeOAuth.get_authorize_url()[0])),
    path('gitee/callback', GiteeOAuth.handle_callback),
    path('oauth/feishu/login', lambda request: redirect(FeishuOAuth.get_authorize_url()[0])),
    path('oauth/feishu/callback', FeishuOAuth.handle_callback),
    
    # Home应用API路由
    path('', home_views.index, name='index'),
    path('api/departments/', home_views.get_departments, name='get_departments'),
    path('api/departments/<int:department_id>/doctors/', home_views.get_doctors_by_department, name='get_doctors_by_department'),
    path('api/doctors/', home_views.get_doctors_list, name='get_doctors_list'),
    path('api/doctors/<int:doctor_id>/', home_views.get_doctor_detail, name='get_doctor_detail'),
    path('api/doctors/<int:doctor_id>/times/', home_views.get_doctor_available_times, name='get_doctor_available_times'),
    path('api/appointments/', home_views.create_appointment_simple, name='create_appointment_simple'),
    path('api/appointments/auth/', home_views.create_appointment, name='create_appointment'),
    path('api/appointments/my/', home_views.get_my_appointments_simple, name='get_my_appointments_simple'),
    path('api/appointments/my/auth/', home_views.get_my_appointments, name='get_my_appointments'),
    path('api/appointments/debug/', home_views.debug_appointments, name='debug_appointments'),
    path('api/map/hospitals/', home_views.list_hospitals, name='list_hospitals'),
    path('api/knowledge/categories/', home_views.get_knowledge_categories, name='get_knowledge_categories'),
    path('api/knowledge/articles/', home_views.get_knowledge_articles, name='get_knowledge_articles'),
    
    # 迭代器模式API路由
    path('api/doctors/iterator/', home_views.get_doctors_with_iterator_filter, name='get_doctors_with_iterator_filter'),
    path('api/appointments/add/', home_views.add_doctor_to_appointments, name='add_doctor_to_appointments'), 
    path('api/appointments/iterator/', home_views.get_my_appointments_with_iterator, name='get_my_appointments_with_iterator'),
    path('api/appointments/cancel/', home_views.cancel_appointment_with_iterator, name='cancel_appointment_with_iterator'),
    path('api/test-auth/', home_views.test_auth_status, name='test_auth_status'),
    path('api/appointments/simple/', home_views.add_appointment_simple, name='add_appointment_simple'),
    
    # 认证相关API路由
    path('api/auth/profile/', auth_views.get_user_profile, name='get_user_profile'),
    path('api/auth/protected/', auth_views.get_protected_data, name='get_protected_data'),
    path('api/auth/admin/', auth_views.admin_operation, name='admin_operation'),
    path('api/auth/session/', auth_views.get_session_data, name='get_session_data'),
    path('api/auth/dingtalk/', auth_views.dingtalk_user_info, name='dingtalk_user_info'),
    path('api/auth/secure-update/', auth_views.secure_update, name='secure_update'),
    
    # Iterator应用API路由
    path('iterator/audit/', iterator_views.audit_medical_records, name='audit_medical_records'),
    
    # Recognition应用API路由
    path('recognition/', include(recognition_urls)),
]